import { Company } from "src/modules/company/company.entity";
import { User } from "src/modules/user/user.entity";
import {
  BeforeInsert,
  Column,
  CreateDateColumn,
  Entity,
  ManyToOne,
  PrimaryGeneratedColumn,
} from "typeorm";

@Entity()
export class Log {
  @PrimaryGeneratedColumn("uuid")
  id: string;

  @ManyToOne(() => User, (user) => user.logs)
  user: User;

  @ManyToOne(() => Company, (company) => company.logs)
  company: Company;

  @Column()
  targetId: string;

  @Column("varchar")
  type:
    | "Bank"
    | "Client"
    | "Company"
    | "Delivery"
    | "Order"
    | "Quality"
    | "Type"
    | "User";

  @Column("varchar")
  method: "PUT" | "DELETE" | "POST";

  @CreateDateColumn()
  date: Date;
}
